package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/29 12:13
 */
public class LS45 {
    public int jump(int[] nums) {
        //可以走到的最大位置
        int maxLen = 0;
        //步数
        int setp = 0;

        int bord = 0;

        for (int i = 0; i < nums.length-1; i++) {
           maxLen = Math.max(i + nums[i],maxLen);
           if (i == bord) {
               setp++;
               bord = maxLen;
           }

        }
        return setp;
    }
}
